home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Memberlist.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  10.3 KB  |  291 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Show all the members
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 20th February 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. $idx = new Memberlist;
  26.  
  27. class Memberlist {
  28.  
  29.     var $output     = "";
  30.     var $page_title = "";
  31.     var $nav        = array();
  32.     var $html       = "";
  33.     var $base_url   = "";
  34.  
  35.     var $first       = 0;
  36.     var $max_results = 10;
  37.     var $sort_key    = 'name';
  38.     var $sort_order  = 'asc';
  39.     var $filter      = 'ALL';
  40.     
  41.     var $mem_titles = array();
  42.     var $mem_groups = array();
  43.     
  44.     
  45.     function Memberlist() {
  46.         global $ibforums, $DB, $std, $print;
  47.         
  48.         
  49.         if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = 'listall';
  50.         
  51.         //--------------------------------------------
  52.         // Require the HTML and language modules
  53.         //--------------------------------------------
  54.         
  55.         $ibforums->lang = $std->load_words($ibforums->lang, 'lang_mlist', $ibforums->lang_id );
  56.         
  57.         require "./Skin/".$ibforums->skin_id."/skin_mlist.php";
  58.         
  59.         $this->html = new skin_mlist();
  60.         
  61.         $this->base_url        = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
  62.         
  63.         if ($ibforums->member['g_mem_info'] != 1)
  64.          {
  65.              $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
  66.         }
  67.         
  68.         //--------------------------------------------
  69.         // Get the member groups, member titles stuff
  70.         //--------------------------------------------
  71.         
  72.         $DB->query("SELECT g_title, g_id, g_icon from ibf_groups ORDER BY g_title");
  73.         
  74.         while ($row = $DB->fetch_row() )
  75.         {
  76.             $this->mem_groups[ $row['g_id'] ] = array( 'TITLE'  => $row['g_title'],
  77.                                                        'ICON'   => $row['g_icon'],
  78.                                                      );
  79.         }
  80.         
  81.         unset($row);
  82.         
  83.         $DB->free_result();
  84.         
  85.         $DB->query("SELECT title, id, posts, pips from ibf_titles ORDER BY posts DESC");
  86.         
  87.         while ($row = $DB->fetch_row() )
  88.         {
  89.             $this->mem_titles[ $row['id'] ] = array( 'TITLE'   => $row['title'],
  90.                                                      'POSTS'   => $row['posts'],
  91.                                                      'PIPS'    => $row['pips'],
  92.                                                      
  93.                                                    );
  94.         }
  95.         
  96.         unset($row);
  97.         
  98.         $DB->free_result();
  99.         
  100.         $the_filter  = array( 'ALL' => $ibforums->lang['show_all'] );
  101.         
  102.         foreach($this->mem_groups as $id => $data)
  103.         {
  104.             if ($id == $ibforums->vars['guest_group'])     continue;
  105.             if ($id == $ibforums->vars['auth_group']) continue;
  106.             if ($id == $ibforums->vars['ban_group'])    continue;
  107.             $the_filter[$id] = $data['TITLE'];
  108.         }
  109.         
  110.         if (isset($ibforums->input['st']))          $this->first       = $ibforums->input['st'];
  111.         if (isset($ibforums->input['max_results'])) $this->max_results = $ibforums->input['max_results'];
  112.         if (isset($ibforums->input['sort_key']))    $this->sort_key    = $ibforums->input['sort_key'];
  113.         if (isset($ibforums->input['sort_order']))  $this->sort_order  = $ibforums->input['sort_order'];
  114.         if (isset($ibforums->input['filter']))      $this->filter      = $ibforums->input['filter'];
  115.         
  116.         $the_sort_key = array( 'name'    => 'sort_by_name',
  117.                                'posts'   => 'sort_by_posts',
  118.                                'joined'  => 'sort_by_joined',
  119.                              );
  120.                              
  121.         $the_max_results = array( 10  => '10',
  122.                                   20  => '20',
  123.                                   30  => '30',
  124.                                   40  => '40',
  125.                                   50  => '50',
  126.                                 );
  127.                                 
  128.         $the_sort_order = array(  'desc' => 'descending_order',
  129.                                   'asc'  => 'ascending_order',
  130.                                );
  131.                                
  132.         $filter_html      = "<select name='filter' class='forminput'>\n";
  133.         $sort_key_html    = "<select name='sort_key' class='forminput'>\n";
  134.         $max_results_html = "<select name='max_results' class='forminput'>\n";
  135.         $sort_order_html  = "<select name='sort_order' class='forminput'>\n";
  136.         
  137.         foreach ($the_sort_order as $k => $v) {
  138.             $sort_order_html .= $k == $this->sort_order ? "<option value='$k' selected>" . $ibforums->lang[ $the_sort_order[ $k ] ] . "\n"
  139.                                                         : "<option value='$k'>"          . $ibforums->lang[ $the_sort_order[ $k ] ] . "\n";
  140.         }
  141.          foreach ($the_filter as $k => $v) {
  142.             $filter_html .= $k == $this->filter ? "<option value='$k' selected>"         . $the_filter[ $k ] . "\n"
  143.                                                         : "<option value='$k'>"          . $the_filter[ $k ] . "\n";
  144.         }       
  145.         foreach ($the_sort_key as $k => $v) {
  146.             $sort_key_html .= $k == $this->sort_key ? "<option value='$k' selected>"     . $ibforums->lang[ $the_sort_key[ $k ] ] . "\n"
  147.                                                         : "<option value='$k'>"          . $ibforums->lang[ $the_sort_key[ $k ] ] . "\n";
  148.         }        
  149.         foreach ($the_max_results as $k => $v) {
  150.             $max_results_html .= $k == $this->max_results ? "<option value='$k' selected>". $the_max_results[ $k ] . "\n"
  151.                                                         : "<option value='$k'>"          . $the_max_results[ $k ] . "\n";
  152.         }
  153.         
  154.         $ibforums->lang['sorting_text'] = preg_replace( "/<#FILTER#>/"      , $filter_html."</select>"     , $ibforums->lang['sorting_text'] );
  155.         $ibforums->lang['sorting_text'] = preg_replace( "/<#SORT_KEY#>/"    , $sort_key_html."</select>"   , $ibforums->lang['sorting_text'] );
  156.         $ibforums->lang['sorting_text'] = preg_replace( "/<#SORT_ORDER#>/"  , $sort_order_html."</select>" , $ibforums->lang['sorting_text'] );
  157.         $ibforums->lang['sorting_text'] = preg_replace( "/<#MAX_RESULTS#>/" , $max_results_html."</select>", $ibforums->lang['sorting_text'] );
  158.         
  159.         $error = 0;
  160.         
  161.         if (! isset($the_sort_key[ $this->sort_key ]) )       $error = 1;
  162.         if (! isset($the_sort_order[ $this->sort_order ]) )   $error = 1;
  163.         if (! isset($the_filter[ $this->filter ]) )           $error = 1;
  164.         if (! isset($the_max_results[ $this->max_results ]) ) $error = 1;
  165.         
  166.         if ($error == 1 )
  167.         {
  168.             $std->Error( array( LEVEL=> 5, MSG =>'incorrect_use') );
  169.         }
  170.         
  171.         //---------------------------------------------
  172.         // Find out how many members match our criteria
  173.         //---------------------------------------------
  174.         
  175.         $q_extra    = $this->filter == 'ALL'     ? ''    : " and mgroup='".$this->filter."' ";
  176.         
  177.         
  178.         $DB->query("SELECT COUNT(id) as total_members FROM ibf_members WHERE id > 0".$q_extra);
  179.         $max = $DB->fetch_row();
  180.         
  181.         $DB->free_result();
  182.         
  183.         $links = $std->build_pagelinks(  array( 'TOTAL_POSS'  => $max['total_members'],
  184.                                                 'PER_PAGE'    => $this->max_results,
  185.                                                 'CUR_ST_VAL'  => $this->first,
  186.                                                 'L_SINGLE'     => "",
  187.                                                 'L_MULTI'      => $ibforums->lang['pages'],
  188.                                                 'BASE_URL'     => $this->base_url."&act=Members&max_results={$this->max_results}&filter={$this->filter}&sort_order={$this->sort_order}&sort_key={$this->sort_key}"
  189.                                               )
  190.                                        );
  191.                                        
  192.         $this->output = $this->html->start();
  193.                                        
  194.         $this->output .= $this->html->Page_header( array( 'SHOW_PAGES' => $links) );  
  195.         
  196.         //-----------------------------
  197.         // START THE LISTING
  198.         //-----------------------------
  199.         
  200.         $DB->query("SELECT name, id, posts, joined, mgroup, email,title, hide_email, location, aim_name, icq_number "
  201.                   ."FROM ibf_members WHERE id > 0".$q_extra." ORDER BY ".$this->sort_key." ".$this->sort_order." LIMIT ".$this->first.",".$this->max_results);
  202.         
  203.         while($member = $DB->fetch_row() )
  204.         {
  205.         
  206.             $pips = 0;
  207.             
  208.             foreach($this->mem_titles as $k => $v)
  209.             {
  210.                 if ($member['posts'] >= $v['POSTS']) {
  211.                     if (!$member['title'])
  212.                     {
  213.                         $member['title'] = $this->mem_titles[ $k ]['TITLE'];
  214.                     }
  215.                     $pips = $v['PIPS'];
  216.                     break;
  217.                 }
  218.             }
  219.             
  220.             if ($this->mem_groups[ $member['mgroup'] ]['ICON'])
  221.             {
  222.                 $member[MEMBER_PIPS_IMG] = "<img src='{$ibforums->vars[TEAM_ICON_URL]}/{$this->mem_groups[ $member['mgroup'] ][ICON]}' border='0'>";
  223.             }
  224.             else
  225.             {
  226.                 if ($pips)
  227.                 {
  228.                     if (preg_match( "/^\d+$/", $pips ) )
  229.                     {
  230.                         for ($i = 1; $i <= $pips; ++$i)
  231.                         {
  232.                             $member['MEMBER_PIPS_IMG'] .= $ibforums->skin['A_STAR'];
  233.                         }
  234.                     }
  235.                     else
  236.                     {
  237.                         $member['MEMBER_PIPS_IMG'] = "<img src='{$ibforums->vars[TEAM_ICON_URL]}/$pips' border='0'>";
  238.                     }
  239.                 }
  240.             }
  241.                                    
  242.             $member['MEMBER_JOINED'] = $std->get_date( $member['joined'], 'JOINED' );
  243.             
  244.             $member['MEMBER_GROUP']  = $this->mem_groups[ $member['mgroup'] ]['TITLE'];
  245.             
  246.             
  247.             if (!$member['hide_email']) {
  248.                 $member['MEMBER_EMAIL'] = "<a href='{$this->base_url}&act=Mail&CODE=00&MID={$member['id']}'>{$ibforums->skin[P_EMAIL]}</a> ";
  249.             } else {
  250.                 $member['MEMBER_EMAIL'] = ' ';
  251.             }
  252.             
  253.             if ($member['icq_number']) {
  254.                 $member['ICQNUMBER'] = "<a href=\"javascript:PopUp('{$this->base_url}&act=ICQ&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_ICQ]}</a> ";
  255.             } else {
  256.                 $member['ICQNUMBER'] = ' ';
  257.             }
  258.             
  259.             if ($member['aim_name']) {
  260.                 $member[AOLNAME] = "<a href=\"javascript:PopUp('{$this->base_url}&act=AOL&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_AOL]}</a> ";
  261.             } else {
  262.                 $member['AOLNAME'] = ' ';
  263.             }
  264.             
  265.             $member['password'] = "";
  266.             
  267.             $member['MEMBER_NAME'] = $member['name'];
  268.             
  269.             $member['MEMBER_POSTS'] = $member['posts'];
  270.             
  271.             $member['MEMBER_ID']    = $member['id'];
  272.             
  273.             $this->output .= $this->html->show_row($member);
  274.             
  275.         }
  276.         
  277.         $this->output .= $this->html->Page_end();
  278.         
  279.         $this->output .= $this->html->end( array( 'SHOW_PAGES' => $links) );
  280.         
  281.         $print->add_output("$this->output");
  282.         $print->do_output( array( 'TITLE' => $ibforums->lang['page_title'], 'JS' => 0, NAV => array( $ibforums->lang['page_title'] ) ) );
  283.             
  284.      }
  285.      
  286.      
  287.     
  288. }
  289.  
  290. ?>
  291.